Project Commands


The purpose of project commands is handling of application pages, their appearance, project loading and exiting. Pages in MMB are displayed at the editor's bottom toolbar:

 

FirstPage()
Description
 


Moves to first page of project.


If there's page startup script, it will be executed.

Code Example
 
FirstPage()
Additional Info
 
If you're using visible PlugIns, it is recommended to use their (PlugIn-specific) commands for hiding before changing project page.

 

LastPage()
Description
 


Moves to last page of project.


If there's page startup script, it will be executed.

Code Example
 
LastPage()
Additional Info
 
If you're using visible PlugIns, it is recommended to use their (PlugIn-specific) commands for hiding before changing project page.

 

NextPage()
Description
 


Moves to next page of project.


If there's page startup script, it will be executed.

Code Example
 
NextPage()
Additional Info
 
If you're using visible PlugIns, it is recommended to use their (PlugIn-specific) commands for hiding before changing project page.

 

PrevPage()
Description
 


Moves to previous page of project.


If there's page startup script, it will be executed.

Code Example
 
PrevPage()
Additional Info
 
If you're using visible PlugIns, it is recommended to use their (PlugIn-specific) commands for hiding before changing project page.

 

Page("Page")
Description
 


Moves to page set by label parameter inside parenthesis and quotes.

Using LASTPAGE as parameter will load last visited page.


If there's page startup script, it will be executed.

Code Examples
 

Page("Page 4")
**(loads page labeled Page 4)

Page("LASTPAGE")
**(loads last visited page)

Additional Info
 
If you're using visible PlugIns, it is recommended to use their (PlugIn-specific) commands for hiding before changing project page.

 

Minimize()
Description
 


Minimizes project window to Windows TaskBar.

Clicking associated taskbar button will restore project window.

Code Example
 
Minimize()
Additional Info
 
Minimizing to tray icon is available through PlugIns like Tweak PlugIn.

 

Restore()
Description
 


Restores project window minimized to Windows TaskBar.

Code Example
 
Restore()

 

Run("Path","CmdLineParams")
Description
 


Runs executable file.

Using this command, you can run any program (.exe), batch file (.bat) or call file with any registered extension that can be viewed by some external program. Command has one required and one optional parameter:

Run("FolderPath-FileName","Parameters-Arguments")

1) program folder path & file name is required

2) Run command parameters or program arguments are optional

Program folder path & file name - either relative (using file path macros) or fixed path with name of file you want to run.

Run command parameters - handle behaviour of executed file and your project when that file is run. 6 comma separated (but without an empty space!) parameters are available:

TOP - executed program will always start on top of the source application (your project), but clicking on another window will move program's window to the background (behind selected window). Setting delay value (in milliseconds) inside parenthesis will pause putting program's window on top. For example: TOP(2000) will wait 2 seconds before setting top position for program's window.

TOPMOST - executed program will be kept on top of all windows (until some other application takes TOPMOST position).
Setting delay value (in milliseconds) inside parenthesis will pause putting program's window on top of all others. For example: TOPMOST(2000) will wait 2 seconds before setting top position for program's window.

WARNING!If you run any application with TOP/TOPMOST flags, MMB always wait until the application initialize (an infinite time). It can be potentially dangerous in cases when the external application cannot start (from any reason), because it can freeze the MMB completely. Therefore, there is an option to set a timeout value to continue with MMB application after a number of milliseconds, no matter if the external application is already initialized or not.

Using the timeout value is required if you use TOP/TOPMOST flags on some nonstandard applications without the "message queue" (for example command.com, cmd.exe or just the bat files, which in fact runs command.com/cmd.exe system apps).

WAIT - your MMB project will wait for run application to finish (close) before any further code line is performed. Useful for calling external encoders, compressors, encryptors and similar programs that require unpredictable amount of time for data processing. Using WAIT parameter, your project won't go out of synchronization with external program.

MAXIMIZE - Activates application's window and displays it as a maximized window.

MINIMIZE - Displays application's window in a minimized mode (i.e application is minimized in Windows taskbar). The project window (MMBuilder) remains active, but only without WAIT parameter.

HIDE - Hides application's window and activates another (main project) window. This parameter is useful if you don't want to display the application window even in minimized mode (for example if you run the bat files). This will start the application with completely hidden main window.

WARNING!!! Be careful with using HIDE parameter, mainly together with WAIT parameter! If application with HIDE and WAIT parameters will not be automatically finished (i.e. without user's input) it will freeze the MMB application! For example, don't use "Pause" command in your bat files if you want to process these files with HIDE&WAIT parameters.

You can use all the above parameters together, separated by comma (without an empty space), but some combinations are useless (e.g. HIDE/MINIMIZE&TOP/TOPMOST):

Run("<SrcDir>\MyApp.exe","TOP(2000),WAIT")

Arguments - various parameters specific to program you're running. For example, running of Notepad can be argumented with name of file you want to run, making it automatically opened upon Notepad run:

Run("<Windows>\notepad.exe","<Windows>\win.ini")

If you want to run Notepad with a text file as a parameter, and with TOPMOST and WAIT, you will have to use this notation...

Run("<Windows>\notepad.exe","WAIT,TOPMOST <Windows>\win.ini")

In other words, first empty space used in second Run command parameter is used as a separator of MMB internal parameters (like WAIT, TOPMOST, etc.) and the program arguments (in this case path to <Windows>\win.ini).

Code Examples
 

** Running Notepad without parameters/arguments:
Run("<Windows>\notepad.exe","")

** Running Notepad with file name as argument:
Run("<Windows>\notepad.exe","<SrcDir>\MyLog.txt")

** Running Notepad using TOP parameter and 2-second delay:
Run("<Windows>\notepad.exe","TOP(2000)")

** Running Calculator on top of all windows:
Run("<System>\calc.exe","TOPMOST")

** Running BladeEnc on top with waiting & sound files in <SrcDir> folder:
Run("<SrcDir>\BladeEnc.exe","TOP,WAIT -128 file.wav file.mp3")

** Running BAT file in HIDE and WAIT mode :
Run("<Embedded>\test.bat","HIDE,WAIT param1 param2")

An advanced example of using WAIT and HIDE with Windows command prompt...
** on WinNT/XP
If (UsingWinNT()) Then
  
** this will list all directories from a given drive and save the obtained list to txt file
  Run("<System>\cmd.exe","WAIT,HIDE /C dir d:\ /A:D /B /O:N /s > c:\outputfile.txt")
** on Win9x/ME
Else
  Run("c:\command.com","WAIT,HIDE /C dir d:\ /A:D /B /O:N /s > c:\outputfile.txt")
End
** and finally, load the saved list to ListBox
ListBoxAddItem("ListBox","c:\outputfile.txt")

Additional Info
 

It is recommended to, whenever possible, run programs/files using relative paths. Read more about path macros here.

This command sends return values from the running application (if return codes were implemented in application) to CBK_ReturnVal constant.

Known Limitations
 
  • TOP/TOPMOST parameters don't support child windows (only the first (main) application window can be set as TOP/TOPMOST).
  • The applications without PID (Process ID) number may not work with TOP/TOPMOST flags.
  • The external application will not be automatically closed if you close the source MMB application.
  • Timout value is required for TOP/TOPMOST parameters used for console applications (command.com, cmd.exe, bat files) or any nonstandard applications without the "message queue". Otherwise TOP/TOPMOST parameter will freeze MMB application.

 

RunMBD("Path","Parameters")
Description
 


Runs another MMB project file with MBD extension.

To avoid large distributions of numerous compiled EXE files, using MMB you can compile only one project file and then run all others using that same compiled EXE. This is possible because project file is only attached to interpreter that represents your compiled EXE project. If it can run attached MBD, why not make it possible to run external ones too ?

This is very neat feature that reduces requirements for both RAM and distribution memory capacity, while MBD files are much smaller than executable files.

Using Compress & Export dialogbox:


...every MBD file can be:

  •  Compressed - using one of 8 compression levels
  •  Password-protected - editing of files in MMB editor will require  password input
  •  Encrypted using Secure Layer - attended to project distribution  purposes, encrypted files won't be editable again

Thus you don't have to worry about distributing MBD project files.

Command has one required and one optional parameter:

RunMBD("FolderPath-FileName","Page Label")

1) folder path & MBD file name - required

2) Label of displayed page in loaded MBD - optional

Program folder path & file name - either relative (using file path macros) or fixed path with name of MBD file you want to run

Parameters:

    NEW_WINDOW - (optional parameter) starts MBD project in a new window.

    Page Label - (optional parameter) once MBD file is loaded, MMB can automatically display the page specified using the Page Label parameter.

Code Examples
 

** Running Program2.mbd from <SrcDir> without page label:
RunMBD("<SrcDir>\Program2.mbd","")

** Running Program2.mbd from <SrcDir> with page label:
RunMBD("<SrcDir>\Program2.mbd","Page 2")

** Running Program2.mbd from <SrcDir> with page label and in new window:
RunMBD("<SrcDir>\Program2.mbd","NEW_WINDOW,Page 2")

Additional Info
 

NEW_WINDOW can be used together with Page Label parameter (separated by comma) or individually.

NEW_WINDOW must be used in front of PageLabel parameter

Page Label now can be used also with "Run another project" trigger action in "External Commands and Page Actions".

It is recommended to, whenever possible, run programs/project files using relative paths. Read more about path macros here.

 

Exit()
Description
 


Closes application.

If your project allows user input that becomes permanent part of application, make sure to save inputed data before exiting.

Code Example
 
Exit()
Additional Info
 
Closing of application is by default also available using ESC (Escape) key on the keyboard. To disable this, use CBK_EXIT object on Master Top Layer. Read about CBK constants for more info.

 

MMB Scripting Unleashed by Bokzy, 2003 :: All rights reserved :: http://www.bokzy.com